package com.ruoyi.system.mongo.Impl;

import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.domain.mongodb.Klasses;
import com.ruoyi.system.mongo.KlassesDao;
import org.bson.types.ObjectId;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @Author HP
 * @Date 2021/3/21
 * @Description TODO
 */
@Repository
public class KlassesDaoImpl implements KlassesDao{
    @Autowired
    private MongoTemplate mongoTemplate;
    @Override
    public List<Klasses> selectSchool(String school) {
            if (StringUtils.isEmpty(school)) {
                return null;
            }
            Query query = new Query(Criteria.where("school").is(new ObjectId(school)));
            List<Klasses> klassesList = mongoTemplate.find(query, Klasses.class);
            return klassesList;
    }
}
